package ${packageName};

<#list importList as item>
import ${item};
</#list>

<#assign serviceVarName = serviceName?substring(0,1)?lower_case+serviceName?substring(1)>
<#assign entityVarName = entityClassName?substring(0,1)?lower_case+entityClassName?substring(1)>
@Api(tags = {"${apiName}Api接口"})
@RestController
@RequestMapping("/${modelName?uncap_first}")
public class ${controllerName}{

    @Autowired
    ${serviceName} ${serviceVarName};

    @ApiOperation(value = "获取所有的记录",notes = "没有分页功能")
    @PostMapping("/selectAll")
    public List<${entityClassName}> selectAll(){
        return ${serviceVarName}.selectAll();
    }

    @ApiOperation(value = "筛选符合条件的记录")
    @PostMapping("/getSelective")
    public List<${entityClassName}> getSelective(${entityClassName} ${entityVarName}){
        return ${serviceVarName}.getSelective(${entityVarName});
    }

    @ApiOperation(value = "获取所有的记录",notes = "有分页功能")
    @PostMapping("/selectWithPage")
    public  Map<String,Object> selectWithPage(@RequestBody Map map){
        return ${serviceVarName}.selectWithPage(map);
    }

    @ApiOperation(value = "根据主键来获取记录")
    @PostMapping("/getByPrimaryKey")
    public ${entityClassName} getByPrimaryKey(@RequestParam ${primaryKey.type} ${primaryKey.varName}){
        return ${serviceVarName}.getByPrimaryKey(${primaryKey.varName});
    }

    @ApiOperation(value = "更新记录")
    @PostMapping("/update")
    public int update(@RequestBody ${entityClassName} ${entityVarName}){
        return ${serviceVarName}.update(${entityVarName});
    }

    @ApiOperation(value = "插入记录")
    @PostMapping("/insert")
    public int insert(@RequestBody @Valid ${entityClassName} ${entityVarName}){
    return ${serviceVarName}.insert(${entityVarName});
    }

    @ApiOperation(value = "插入记录",notes = "存在即更新")
    @PostMapping("/saveOrUpdate")
    public int saveOrUpdate(@RequestBody @Valid ${entityClassName} ${entityVarName}){
        return ${serviceVarName}.saveOrUpdate(${entityVarName});
    }

    @ApiOperation(value = "删除记录")
    @PostMapping("/delete")
    public int delete(@RequestParam ${primaryKey.type} ${primaryKey.varName}){
        return ${serviceVarName}.delete(${primaryKey.varName});
    }
}
